
//修改BOM
function updateBom() {

	var hd = document.getElementsByName("h");
	var cs = document.getElementsByName("bomID");
	// var formList = document.getElementsByTagName("formLIst");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.formList.action = 'bom!updateInput.action';
		document.formList.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 删除BOM
function delBom() {

	var hd = document.getElementsByName("h");
	var cs = document.getElementsByName("bomID");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.formList.action = 'bom!del.action';
		document.formList.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 审核BOM
function checkBom() {

	var hd = document.getElementsByName("h");
	var cs = document.getElementsByName("bomID");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.formList.action = 'bom!check.action';
		document.formList.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 修改支付方式
function updatePayType() {

	var hd = document.getElementsByName("checkbox1");
	var cs = document.getElementsByName("ioTypeId");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.formList1.action = 'payType!updateInput.action';
		document.formList1.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 删除支付方式
function delPayType() {

	var hd = document.getElementsByName("checkbox1");
	var cs = document.getElementsByName("ioTypeId");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.formList1.action = 'payType!del.action';
		document.formList1.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 修改物料
function updateMaterial() {

	var hd = document.getElementsByName("checkbox2");
	var cs = document.getElementsByName("materialId");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.materialList.action = 'materail!updateInput.action';
		document.materialList.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 删除物料
function delMaterial() {

	var hd = document.getElementsByName("checkbox2");
	var cs = document.getElementsByName("materialId");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.materialList.action = 'materail!del.action';
		document.materialList.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 修改销售价格
function updateSalePrice() {

	var hd = document.getElementsByName("checkbox3");
	var cs = document.getElementsByName("priceListId");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.saleList.action = 'salePrice!updateInput.action';
		document.saleList.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 删除销售价格
function delSalePrice() {

	var hd = document.getElementsByName("checkbox3");
	var cs = document.getElementsByName("priceListId");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.saleList.action = 'salePrice!del.action';
		document.saleList.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}

// 修改采购价格
function updateStockPrice() {

	var hd = document.getElementsByName("checkbox4");
	var cs = document.getElementsByName("stockPriceId");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.stockList.action = 'stockPrice!updateInput.action';
		document.stockList.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 删除采购价格
function delStockPrice() {

	var hd = document.getElementsByName("checkbox4");
	var cs = document.getElementsByName("stockPriceId");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.stockList.action = 'stockPrice!del.action';
		document.stockList.submit();
		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 修改辅助资料
function updateHelp() {

	var hd = document.getElementsByName("ch");
	var cs = document.getElementsByName("id");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.helpList.action = 'help!updateInput.action';
		document.helpList.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 删除辅助资料
function delHelp() {

	var hd = document.getElementsByName("ch");
	var cs = document.getElementsByName("id");

	var g = 0;
	for ( var k = 0; k < cs.length; k++) {
		if (cs[k].checked == true) {
			g++;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else {
		document.helpList.action = 'help!del.action';
		document.helpList.submit();

		if (hd[0].checked == true) {
			hd[0].checked = false;
		}
	}
}
// 删除出库单
function delOut(action,method) {
	var cs = document.getElementsByName("outStorageId");
	var out = document.getElementsByName("outStorage");
	var g = 0;
	for ( var k = 0; k < cs.length; k=k+1) {
		if (cs[k].checked) {
			g=g+1;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else if(g==1){
		
		out[0].action = action+'!'+method+'.action';
		out[0].submit();

	}

}

//增加行
function addRow()
{
	var t =document.getElementById("mbody") ;
	var row = t.insertRow(t.rows.length); 
	var i = t.rows.length - 2; 
	var id = "textSuggest" + i;
	var col = row.insertCell(0);
	col.innerHTML = "<td><input  type='checkbox' name='checkbox'/></td>"; 
	col = row.insertCell(1); 
	col.innerHTML = "<td><input name='unitcosts' type='text' size='8'/></td>"; 
	col = row.insertCell(2); 
	col.innerHTML = "<td><input name='materialId' type='text' size='6'/></td>"; 
	col = row.insertCell(3); 
	col.innerHTML = "<td><input name='wareHouseId' type='text' size='8'/></td>"; 
	col = row.insertCell(4); 
	col.innerHTML = "<td><input name='shouldSendAmoun' type='text' size='8'/></td>"; 
	
	col = row.insertCell(5); 
	col.innerHTML = "<td><input name='sendAmoun' type='text'size='7'/></td>";
	col = row.insertCell(6); 
	col.innerHTML = "<td><input name='cost' type='text'size='7'/></td>";    
	col = row.insertCell(7); 
	col.innerHTML = "<td><input name='temp1' type='text'size='7'/></td>";    
	
}
//操作销售发票没
function delSale(action,method) {
	var cs = document.getElementsByName("sellSlipId");
	var out = document.getElementsByName("saleInvoice");
	var g = 0;
	for ( var k = 0; k < cs.length; k=k+1) {
		if (cs[k].checked) {
			g=g+1;
		}
	}
	if (g == 0) {
		alert("你还没有进行选择");
	} else if (g > 1) {
		alert("只能选择一条记录");
	} else if(g==1){
		
		out[0].action = action+'!'+method+'.action';
		out[0].submit();

	}

}

//bom
function addRowBOM()
{
	var t =document.getElementById("mbody") ;
	var row = t.insertRow(t.rows.length); 
	var i = t.rows.length - 2; 
	var id = "textSuggest" + i;
	var col = row.insertCell(0);
	col.innerHTML = "<td><input  type='checkbox' name='checkbox'/></td>"; 
	col = row.insertCell(1); 
	col.innerHTML = "<td><input name='itemID' type='text' size='8'/></td>"; 
	col = row.insertCell(2); 
	col.innerHTML = "<td><input name='bomID' type='text' size='6'/></td>"; 
	col = row.insertCell(3); 
	col.innerHTML = "<td><input name='usedState' type='text' size='8'/></td>"; 
	col = row.insertCell(4); 
	col.innerHTML = "<td><input name='baseUsedAmount' type='text' size='8'/></td>"; 
	
	col = row.insertCell(5); 
	col.innerHTML = "<td><input name='usedAmount' type='text'size='7'/></td>";
	col = row.insertCell(6); 
	col.innerHTML = "<td><input name='materialUnitID' type='text'size='7'/></td>";    
	col = row.insertCell(7); 
	col.innerHTML = "<td><input name='wareHouseID' type='text'size='7'/></td>";    
	
}